package domain;

import java.util.Date;
import java.util.Objects;

/**
 * 用户类
 *
 * @author liujiale
 */
public class User extends StudentAccount {

    /** 用户ID */
    private int userID;

    /**
     * 实现StudentAccount的构造函数，不带userID
     *
     * @param gender    性别，男性为true，女性为false
     * @param college   学院
     * @param studentID 学生ID
     */
    public User(boolean gender, String college, String studentID) {
        super(gender, college, studentID);
    }

    /**
     * 实现StudentAccount的构造函数，带userID
     *
     * @param gender    性别，男性为true，女性为false
     * @param college   学院
     * @param studentID 学生ID
     * @param userID    用户ID
     */
    public User(boolean gender, String college, String studentID, int userID) {
        super(gender, college, studentID);
        this.userID = userID;
    }

    /**
     * 实现Account和StudentAccount的构造函数，带userID
     *
     * @param username   用户名
     * @param password   密码
     * @param nickname   昵称
     * @param telephone  电话
     * @param email      邮箱
     * @param createTime 账户创建时间
     * @param gender      性别，男性为true，女性为false
     * @param college     学院
     * @param studentID   学生ID
     * @param userID    用户ID
     */
    public  User(String username, String password, String nickname, String telephone, String email, Date createTime, boolean gender, String college, String studentID, int userID) {
        super(username, password, nickname, telephone, email, createTime, gender, college, studentID);
        this.userID = userID;
    }

    public User() {

	}

	/**
     * Gets user id.
     *
     * @return the user id
     */
    public int getUserID() {
        return userID;
    }

    /**
     * Sets user id.
     *
     * @param userID the user id
     */
    public void setUserID(int userID) {
        this.userID = userID;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof User)) {
            return false;
        }
        User user = (User) o;
        return userID == user.userID;
    }

    @Override
    public int hashCode() {
        return Objects.hash(userID);
    }

    @Override
    public String toString() {
        return "User{" +
                "userID=" + userID +
                '}';
    }
}
